package tech.yunland.shop.domain.model;

import com.alibaba.fastjson.annotation.JSONField;
import com.moyuer.bsf.domain.model.AbstractEntity;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 * 标签下的商品
 *
 * @author: 袁首京<yuanshoujing@gmail.com>
 * 16/3/29
 */
@Entity
@Table(name = "tag_goods")
public class TagGoods extends AbstractEntity {

	@JSONField(serialize = false)
    @ManyToOne
    private Tag tag;

    @JSONField(serialize = false)
    @ManyToOne
    private Goods goods;

    @Transient
    private String tagId;

    @Transient
    private String tagName;

    @Transient
    private String goodsId;

    @Transient
    private String goodsName;



    public Tag getTag() {
        return tag;
    }

    public void setTag(Tag tag) {
        this.tag = tag;
    }

    public Goods getGoods() {
        return goods;
    }

    public void setGoods(Goods goods) {
        this.goods = goods;
    }

	public String getTagName() {
		if (tagName != null) {
            return tagName;
        }

        if (tag != null) {
            tagName = tag.getName();
        }

        return tagName;
	}

	public void setTagName(String tagName) {
		this.tagName = tagName;
	}

	public String getGoodsName() {
		if (goodsName != null) {
			return goodsName;
		}

		if (goods != null) {
			goodsName = goods.getName();
		}

		return goodsName;
	}

	public void setGoodsName(String goodsName) {
		this.goodsName = goodsName;
	}

	public String getTagId() {
		if (tagId != null) {
			return tagId;
		}

		if (tag != null) {
			tagId = tag.getId();
		}

		return tagId;
	}

	public void setTagId(String tagId) {
		this.tagId = tagId;
	}

	public String getGoodsId() {
		if (goodsId != null) {
			return goodsId;
		}

		if (goods != null) {
			goodsId = goods.getId();
		}

		return goodsId;
	}

	public void setGoodsId(String goodsId) {
		this.goodsId = goodsId;
	}
}
